#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QPushButton>
#include <QDialog>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QPushButton* button = new QPushButton(this);

    button->setGeometry(300, 200, 200, 50);

    button->setText("弹出一个对话框");

    connect(button, &QPushButton::clicked, this, &MainWindow::handle);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handle()
{
    QDialog* dialog = new QDialog(this);

    dialog->setWindowTitle("对话框");

    dialog->resize(200, 300);

    dialog->show();

    dialog->setAttribute(Qt::WA_DeleteOnClose);

}

